package demo.xlj.yuyi.studentapp.rxjava;

import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;

/**
 * Created by whstywh on 2017/4/18 0018.
 * GitHub：https://github.com/whstywh
 * email：whstywh@163.com
 */

public abstract class BaseScbscribe<T> implements Subscriber<T> {

    private Subscription sub;

    @Override
    public void onSubscribe(Subscription s) {
        sub = s;
        sub.request(1);
    }

    @Override
    public void onNext(T t) {
        _onNext(t);
        sub.request(1);
    }

    @Override
    public void onError(Throwable t) {
        _onError(t);
    }

    @Override
    public void onComplete() {

    }

    public abstract void _onNext(T t);

    public abstract void _onError(Throwable e);
}
